#include <stdio.h>
#define STUDENT_LENGTH 20
int students[STUDENT_LENGTH][2];
int position = -1;
void add(int score)
{
	if(position >= STUDENT_LENGTH)
	{
		return;
	}
	position++;
	students[position][0] = position;
	students[position][1] = score;
}
void print_student(int *s)
{
	printf("id = %d; score = %d;\n",*s,*(s+1));
}
void search_student_by_id(int id,int (*student)[2])
{
	for(int i = 0;i <= position;i++)
	{
		// *(student + i)[0] == *(*(student + i) + 0)
		if(*(student + i)[0] == id)
		{
			print_student(*(student + i));
			return;
		}
	}
	printf("no results\n");
}
void print_all_student(int (*students)[2])
{
	printf("id\tscore\n");
	for(int i = 0;i <= position;i++)
	{
		printf("%d\t%d\n",*(*(students + i) + 0),*(*(students + i) + 1));
	}
}
int main(void)
{
	int action=0,temp=0;
	while(1)
	{
		printf("input your action:");
		scanf("%d",&action);
		while(getchar() != '\n'){};
		switch(action)
		{
			case 1:
				printf("input your score:");
				scanf("%d",&temp);
				add(temp);
				break;
			case 2:
				printf("input your id:");
				scanf("%d",&temp);
				search_student_by_id(temp,students);
				break;
			case 3:
				print_all_student(students);
				break;
			default:
				printf("wrong action!\n");
				break;
		}
		action = 0;
		while(getchar() != '\n'){};
	}
	return 0;
}
